home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Script / Send file, an auto-reply script / Send file auto-reply (text) next >
Encoding:
Text File  |  1994-06-16  |  2.3 KB  |  70 lines  |  [TEXT/ToyS]

  1. -- This script is postcard-ware (or email-ware, if you're so inclined...)
  2. -- Feel free to improve on it as you see fit. Send me a copy if you do!
  3. -- If you like it, please send me a postcard of your hometown!
  4. -- Philippe Casgrain
  5. -- 4 980 Boul. Lalande
  6. -- Pierrefonds, Qc.
  7. -- CANADA  H8Y 1V8
  8.  
  9. property filesToSend : {}
  10. property subjectsToMatch : {}
  11.  
  12. if length of filesToSend is 0 then
  13.     set doneAddingFiles to false
  14.     set oneSubject to ""
  15.     
  16.     repeat until doneAddingFiles
  17.         set oneFile to choose file with prompt ¬
  18.             "Select a file you wish to auto-send please..."
  19.         set theQuestion to (display dialog ¬
  20.             "What substring should the 'Subject:' match with this file?" ¬
  21.             buttons {"Cancel", "OK and Done", "OK and Add more..."} ¬
  22.             default answer oneSubject ¬
  23.             default button "OK and Add more...")
  24.         
  25.         set oneSubject to (text returned of theQuestion)
  26.         
  27.         set filesToSend to filesToSend & oneFile
  28.         set subjectsToMatch to subjectsToMatch & oneSubject
  29.         
  30.         set doneAddingFiles to (button returned of theQuestion is "Ok and Done")
  31.     end repeat
  32. end if
  33.  
  34. tell application "Eudora1.4.2"
  35.     set numberOfMessages to count message in mailbox "In" of mail folder ""
  36.     set curMsg to 1
  37.     set trashMsg to count message in mailbox "Trash" of mail folder ""
  38.     repeat numberOfMessages times
  39.         set doneParsingMessage to false
  40.         set didTrashMessage to false
  41.         set curSubject to 1
  42.         repeat until doneParsingMessage
  43.             if field "Subject:" of message curMsg of mailbox "In" of mail folder "" ¬
  44.                 contains (item curSubject of subjectsToMatch) then
  45.                 move (message curMsg of mailbox "In" of mail folder "") ¬
  46.                     inserthere end of mailbox "Trash" of mail folder ""
  47.                 set trashMsg to trashMsg + 1
  48.                 set theReply to reply (message trashMsg of mailbox "Trash" ¬
  49.                     of mail folder "")
  50.                 attach theReply documentlist (item curSubject of filesToSend)
  51.                 queue theReply queuetype 1
  52.                 set didTrashMessage to true
  53.             else
  54.                 set curSubject to curSubject + 1
  55.             end if
  56.             set doneParsingMessage to ((curSubject > (count of subjectsToMatch)) or didTrashMessage)
  57.         end repeat
  58.         if not didTrashMessage then
  59.             set curMsg to curMsg + 1
  60.         end if
  61.     end repeat
  62.     
  63.     -- Send the queued messages, if any
  64.     if (count message in mailbox "Out" of mail folder "") > 0 then
  65.         with timeout of 36000 seconds -- 10 hour ought to do it...
  66.             connect with send without check
  67.         end timeout
  68.     end if
  69.     
  70. end tell